/*
 * usart.h
 *
 * Copyright 2011 Pieter Agten
 *
 * This file is part of Yarf.
 *
 * Yarf is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Yarf is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Yarf.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * @file   usart.h
 * @author Pieter Agten (pieter.agten@gmail.com)
 * @date   20 sep 2011
 * @brief  Driver for USART0, which is connected to the host.
 *
 */

#ifndef USART_H
#define USART_H

#include <stdbool.h>
#include <stdio.h>



/**
 * Initializes the usart component.
 */
void usart_init(void);

/**
 * If a character is waiting in the USART hardware buffer, this function reads
 * that character and places it into the input buffer.
 *
 * This function can be called from within long interrupt service routines that
 * have higher priority than the USART0_RX interrupt, in order to prevent the
 * hardware buffer from overrunning.
 */
void usart0_try_read_character(void);

/**
 * Stream which can be used to read from and write to the USART.
 */
extern FILE usart0_stream;

#endif // USART_H
